
package com.ifcar.app.rss;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.text.TextUtils;

import com.ifcar.app.activity.HomePage;
import com.ifcar.app.model.Videos;
import com.ifcar.app.util.HttpUtils;
import com.ifcar.app.util.NeteaseHttpClient;
import com.ifcar.app.util.StringUtil;
import com.ifcar.app.util.Tools;
import com.netease.util.Pair;

public class GetColumnsInfo {

    /*
     * 文章列表扩展域 2011-12-16 edited by zhangyp
     */
    public static final String NTES_TAG = "NTES"; // 是否为独家 true or false
    public static final String NEWS_TAG = "TAG"; // 是新闻的tag标记，可以为 外媒、独家等
    public static String[] EXTENDS = new String[] {
            NTES_TAG, NEWS_TAG
    };
    public static final String EX_JSON_TAG = "extendjson";

    public static final String DEL_TAG = "del";
    public static final String CID_TAG = "cid";
    public static final String CNAME_TAG = "cname";

    public static final String TID_TAG = "tid";
    public static final String TNAME_TAG = "tname";
    public static final String TLOCAL_NEWS_TAG = "local_news";

    public static final String HEADLINE_TAG = "headLine";
    public static final String DOCID_TAG = "docid";
    public static final String TITLE_TAG = "title";
    public static final String REPLYCOUNT_TAG = "replyCount";
    public static final String PTIME_TAG = "ptime";
    public static final String URL_TAG = "url";
    public static final String IMGSRC_TAG = "imgsrc";
    public static final String DIGEST_TAG = "digest";
    public static final String SUBTITLE_TAG = "subtitle";// 副标题

    public static final String DOWNLOAD_IMGSRC_TAG = "downloadimg";
    public static final String ORG_IMAGE_TAG = "orgimg";

    public static final String SPECIAL_ID_TAG = "specialID";
    public static final String SPECIAL_INDEX_TAG = "index";
    public static final String SPECIAL_TNAME_TAG = "tname";
    public static final String SDOCID_TAG = "sdocid";
    public static final String SNAME_TAG = "sname";

    public static final String SPECIAL_BANNER = "banner";

    public static final String REPLYBOARD_TAG = "replyBoard";
    public static final String SOURCE_TAG = "source";
    public static final String BODY_TAG = "body";
    public static final String HASNEXT_TAG = "hasNext";
    public static final String IMG_TAG = "img";
    public static final String REF_TAG = "ref";
    public static final String ALT_TAG = "alt";
    public static final String SRC_TAG = "src";
    // 新增字段
    public static final String PICNAWS_TAG = "picnews";
    public static final String VIDEO_TAG = "video";
    public static final String COVER_TAG = "cover";
    public static final String MP4_URL_TAG = "url_mp4";
    public static final String TEMPLATE_TAG = "template";
    public static final String MEDIA_TYPE = "media_type";
    public static final String MEDIA_IMAGE = "media_image";
    public static final String MEDIA_VIDEO = "media_video";
    public static final String PHOTOSET_ID_TAG = "photosetID";
    // ======================
    /* 文章正文链接 */
    public static final String LINK_TAG = "link";
    public static final String HREF_TAG = "href";
    public static final String TYPE_TAG = "type";
    public static final String ID_TAG = "id";

    public static final String POSTID_TAG = "postid";

    public static final String HASIMG_TAG = "hasImg";
    public static final String ORDER_TAG = "order";
    /**
     * 赛程
     */
    public static final String PROJECT_NAME = "event";
    public static final String PROJECT_LIST = "sList";
    public static final String MATCH_NAME = "sName";
    public static final String MATCH_TIME = "sTime";
    public static final String MATCH_LIST = "mList";

    public static final String GAME_START = "mStart";
    public static final String GAME_END = "mEnd";
    public static final String GAME_NAME = "mName";
    public static final String GAME_MEDAL = "medal";
    public static final String GAME_DATE = "date";

    public static final String SCHEDULE_TIME = "scheduleTime";
    /**
     * 话题投票
     */
    public static final String TOPIC = "attitude"; // 话题
    /** 微新闻 */
    public static final String WEIBO_TOPIC_TAG = "weibo_topic";
    public static final String WBLIST_TAG = "wblist";
    public static final String IMAGES_TAG = "imgs";
    public static final String TIME_TAG = "time";
    public static final String REPLYID_TAG = "replyid";
    public static final String TEXT_TAG = "text";
    public static final String M_URL_TAG = "m_url";

    public static final String DefaultColumn_Url = "http://c.3g.163.com/nc/topicset/default.html";
    public static final String Categories_Url = "http://c.3g.163.com/nc/category/list.html";
    public static final String AllCoulumn_Url = "http://c.3g.163.com/nc/topicset/list.html";
    public static final String CoulumnByCategory_Url = "http://c.3g.163.com/nc/topicset/list-by-category/";
    public static final String Headline_list_Url = "http://c.3g.163.com/nc/article/headline/";
    public static final String NonHeadline_list_Url = "http://c.3g.163.com/nc/article/list/";// "http://61.135.251.210/nc/article/list/"
    public static final String Article_Url = "http://c.3g.163.com/nc/article/";
    public static final String Article_shorturl = "http://c.3g.163.com/nc/shorturl/getShort/";
    public static final String Img_shorturl = "http://c.3g.163.com/nc/shorturl/getMicroBlogImg/";
    public static final String LOCAL_NEWS_URL = "http://c.3g.163.com/nc/article/local/";
    private static final String HEADADVERTISMENT_URL = "http://c.3g.163.com/nc/ad/headline/";
    // 搜索api
    // private static final String SearchNews_Url =
    // "http://220.181.8.57:8080/nc/article/search/%s.html";
    private static final String SearchNews_Url = "http://c.3g.163.com/nc/article/search/%s.html";
    // 微热点
    // public static final String MicroHost_Url =
    // "http://220.181.8.57:8080/nc/article/weibo/topic/%s-%s.html";
    public static final String MicroHost_Url = "http://c.3g.163.com/nc/article/weibo/topic/%s-%s.html";

    // http://220.181.8.33:8080/nc/special/
    // http://c.3g.163.com/nc/special/
    public static final String SpcialArticle_Url = "http://c.3g.163.com/nc/special/";//

    // 赛程
    public static final String GameSchedule_Url = "http://c.3g.163.com/olympic/nc/schedule/date/";
    public static final String ItemSchedule_Url = "http://c.3g.163.com/olympic/nc/schedule/event/";

    public static ArrayList<HashMap<String, Object>> getColumnCategories(Context mContext) {
        ArrayList<HashMap<String, Object>> list = new ArrayList<HashMap<String, Object>>();

        JSONArray jsonArray = null;
        JSONObject jobj = null;
        HashMap<String, Object> map = null;

        String results = HttpUtils.getResponseFromGetUrl(Categories_Url, 30000, mContext);

        if (results != null && !results.equals("")) {

            try {
                jsonArray = new JSONArray(results);
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            for (int i = 0; jsonArray != null && i < jsonArray.length(); i++) {
                try {
                    jobj = jsonArray.getJSONObject(i);

                    String del = jobj.getString(DEL_TAG);
                    if (del != null && del.equals("0")) {
                        map = new HashMap<String, Object>();
                        map.put(CID_TAG, jobj.getString(CID_TAG));
                        map.put(CNAME_TAG, jobj.getString(CNAME_TAG));
                        map.put(HEADLINE_TAG, jobj.getBoolean(HEADLINE_TAG));

                        list.add(map);
                    }
                } catch (JSONException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

            }

        }

        return list;
    }

    public static ArrayList<HashMap<String, Object>> getColumnsByCategory(
            String categoryId, Context mContext) {
        ArrayList<HashMap<String, Object>> list = new ArrayList<HashMap<String, Object>>();

        JSONArray jsonArray = null;
        JSONObject jobj = null;
        JSONObject jobj2 = null;
        HashMap<String, Object> map = null;

        String url = CoulumnByCategory_Url + categoryId + ".html";
        String results = HttpUtils.getResponseFromGetUrl(url, 30000, mContext);

        if (results != null && !results.equals("")) {

            try {
                jobj = new JSONObject(results);

                if (jobj != null) {
                    jsonArray = jobj.getJSONArray(categoryId);

                    for (int j = 0; jsonArray != null && j < jsonArray.length(); j++) {
                        try {
                            jobj2 = jsonArray.getJSONObject(j);
                            String del = jobj2.getString(DEL_TAG);
                            if (del != null && del.equals("0")) {
                                map = new HashMap<String, Object>();
                                map.put(TID_TAG, jobj2.getString(TID_TAG));
                                map.put(TNAME_TAG, jobj2.getString(TNAME_TAG));

                                list.add(map);
                            }
                        } catch (Exception e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                    }
                }
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

        }

        return list;
    }

    public static ArrayList<HashMap<String, Object>> getDefaultColumns(Context mContext) {
        ArrayList<HashMap<String, Object>> list = new ArrayList<HashMap<String, Object>>();

        JSONArray jsonArray = null;
        JSONObject jobj = null;
        JSONObject jobj2 = null;
        HashMap<String, Object> map = null;

        String results = HttpUtils.getResponseFromGetUrl(DefaultColumn_Url,
                30000, mContext);

        if (results != null && !results.equals("")) {

            try {
                jobj = new JSONObject(results);
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            if (jobj != null) {
                try {
                    jsonArray = jobj.getJSONArray("default-topicset");

                    for (int j = 0; jsonArray != null && j < jsonArray.length(); j++) {
                        try {
                            map = new HashMap<String, Object>();
                            jobj2 = jsonArray.getJSONObject(j);

                            map.put(CID_TAG, "");
                            String tid = jobj2.getString(TID_TAG);
                            map.put(TID_TAG, tid);
                            map.put(TNAME_TAG, jobj2.getString(TNAME_TAG));
                            list.add(map);

                        } catch (Exception e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                    }
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
        return list;
    }

    public static ArrayList<HashMap<String, Object>> getAllColumns(Context mContext) {
        ArrayList<HashMap<String, Object>> list = new ArrayList<HashMap<String, Object>>();

        JSONArray jsonArray = null;
        JSONObject jobj = null;
        JSONObject jobj2 = null;
        HashMap<String, Object> map = null;

        String results = HttpUtils.getResponseFromGetUrl(AllCoulumn_Url, 30000, mContext);

        if (results != null && !results.equals("")) {

            try {
                jobj = new JSONObject(results);
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            if (jobj != null) {
                Iterator it = jobj.keys();

                for (int i = 0; i < jobj.length(); i++) {
                    try {
                        String key = it.next().toString();
                        jsonArray = jobj.getJSONArray(key);

                        for (int j = 0; jsonArray != null && j < jsonArray.length(); j++) {
                            try {
                                map = new HashMap<String, Object>();
                                jobj2 = jsonArray.getJSONObject(j);
                                String del = jobj2.getString(DEL_TAG);
                                if (del != null && del.equals("0")) {
                                    map.put(CID_TAG, key);
                                    map.put(TID_TAG, jobj2.getString(TID_TAG));
                                    map.put(TNAME_TAG, jobj2.getString(TNAME_TAG));
                                    map.put(HEADLINE_TAG, jobj2.getBoolean(HEADLINE_TAG));
                                    if (jobj2.getBoolean(HEADLINE_TAG)) {
                                        list.add(0, map);
                                    } else {
                                        list.add(map);
                                    }
                                }
                            } catch (Exception e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            }
                        }

                    } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }

                }
            }
        }

        return list;
    }

    public static ArrayList<HashMap<String, Object>> getAllColumnsButHeadline(Context mContext) {
        ArrayList<HashMap<String, Object>> list = new ArrayList<HashMap<String, Object>>();

        JSONArray jsonArray = null;
        JSONObject jobj = null;
        JSONObject jobj2 = null;
        HashMap<String, Object> map = null;

        String results = HttpUtils.getResponseFromGetUrl(AllCoulumn_Url, 30000, mContext);

        if (results != null && !results.equals("")) {

            try {
                jobj = new JSONObject(results);
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            if (jobj != null) {
                Iterator it = jobj.keys();
                for (int i = 0; i < jobj.length(); i++) {
                    try {
                        String key = it.next().toString();
                        jsonArray = jobj.getJSONArray(key);

                        for (int j = 0; jsonArray != null && j < jsonArray.length(); j++) {
                            try {
                                map = new HashMap<String, Object>();
                                jobj2 = jsonArray.getJSONObject(j);
                                String del = jobj2.getString(DEL_TAG);
                                if (del != null && del.equals("0")) {
                                    map.put(CID_TAG, key);
                                    map.put(TID_TAG, jobj2.getString(TID_TAG));
                                    // Log.i(TID_TAG, jobj2.getString(TID_TAG));
                                    map.put(TNAME_TAG, jobj2.getString(TNAME_TAG));
                                    list.add(map);
                                }
                            } catch (Exception e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            }
                        }

                    } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }

                }
                if (list.size() != 0) {
                    map = list.get(list.size() - 1);
                    list.remove(list.size() - 1);
                    list.add(0, map);
                }
            }
        }

        return list;
    }

    /**
     * 获取头条文章列表
     * 
     * @param c
     * @param columnUrl
     * @param columnId
     * @param start
     * @param length
     * @return
     */
    public static List<Map<String, Object>> getHeadlineArticleList(Context c,
            String columnUrl, String columnId, int start, int length) {

        List<Map<String, Object>> list = null;

        JSONArray jsonArray = null;
        JSONObject jobj = null;
        JSONObject jobj2 = null;
        HashMap<String, Object> map = null;

        String url = columnUrl + columnId + "/" + start + "-" + length + ".html";
        String results = HttpUtils.getResponseFromGetUrl(url, 30000, c);

        if (results != null && !results.equals("")) {

            try {
                jobj = new JSONObject(results);

                if (jobj != null) {
                    jsonArray = jobj.getJSONArray(columnId);
                    StringBuilder imgsrc = null;
                    float density = c.getResources().getDisplayMetrics().density;
                    String imgSize = ((int) (73 * density)) + "x" + ((int) (53 * density));
                    list = new ArrayList<Map<String, Object>>();
                    for (int j = 0; jsonArray != null && j < jsonArray.length(); j++) {
//                        try {
                            jobj2 = jsonArray.getJSONObject(j);
                            map = new HashMap<String, Object>();
                            map.put(DOCID_TAG, jobj2.getString(DOCID_TAG));
                            map.put(TITLE_TAG, Tools.htmlDecoder(jobj2.getString(TITLE_TAG)));
                            map.put(REPLYCOUNT_TAG, jobj2.getInt(REPLYCOUNT_TAG) + "跟贴");
                            map.put(URL_TAG, jobj2.getString(URL_TAG));
                            map.put(PTIME_TAG, jobj2.getString(PTIME_TAG));

                            imgsrc = new StringBuilder(jobj2.getString(IMGSRC_TAG));

                            if (start == 0 && j == 0) {
                                map.put(IMGSRC_TAG, imgsrc.toString());
                            } else if (imgsrc.toString().startsWith("http://")) {
                                imgsrc.insert("http://".length(), "s.cimg.163.com/i/");
                                imgsrc.append(".").append(imgSize).append(".auto.jpg");
                                map.put(IMGSRC_TAG, imgsrc.toString());
                            } else {
                                map.put(IMGSRC_TAG, imgsrc.toString());
                            }

                            String digest = jobj2.isNull(DIGEST_TAG) ? "" : jobj2
                                    .getString(DIGEST_TAG);
                            digest = Tools.htmlDecoder(digest);
                            digest = digest.length() > 30 ? digest.substring(0, 28) + ".." : digest;
                            map.put(DIGEST_TAG, digest);
                            map.put(HASIMG_TAG, "1");
                            String specialid = jobj2.isNull(SPECIAL_ID_TAG) ? "" : jobj2
                                    .getString(SPECIAL_ID_TAG);
                            map.put(SPECIAL_ID_TAG, specialid);

                            if (!"".equals(specialid)) {
                                map.put(REPLYCOUNT_TAG, "专题");
                            }
                            map.put(SPECIAL_ID_TAG, specialid);

                            // 加入扩展域
                            map.put(EX_JSON_TAG, Tools.getExtendJson(jobj2).toString());

                            // 获得副标题
                            map.put(SUBTITLE_TAG,
                                    jobj2.isNull(SUBTITLE_TAG) ? "" : jobj2.getString(SUBTITLE_TAG));
                            list.add(map);
//                        } catch (Exception e) {
//                            // TODO Auto-generated catch block
//                            e.printStackTrace();
//                        }
                    }
                }

            } catch (Exception e) {
                e.printStackTrace();
                list = null;
                NeteaseHttpClient.removeCache(c, url);
            }

        }

        if (start == 0 && list != null && list.size() > 0) {
            StringUtil.updateRefreshTime(c, columnId);
        }

        return list;
    }

    /***
     * 获取头图广告图片数据
     * 
     * @param start
     * @param end
     * @param context
     * @return
     */
    public static String getHeadAdvertismentStr(int start, int end, Context context) {

        String url = HEADADVERTISMENT_URL + start + "-" + end + ".html";
        String resultStr = HttpUtils.getResponseFromGetUrl(url, 30000, context);

        return resultStr;
    }

    public static List<Map<String, Object>> getSpecialArticleList(String columnUrl,
            String specialId, Context mContext) {

        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();

        JSONArray jsonArray = null;
        JSONArray jsonArray2 = null;
        JSONObject jobj = null;
        JSONObject jobj2 = null;
        JSONObject jobj3 = null;
        JSONObject jobj4 = null;
        HashMap<String, Object> map = null;
        String url = columnUrl + specialId + ".html";
        String results = HttpUtils.getResponseFromGetUrl(url, 30000, mContext);

        if (results != null && !results.equals("")) {

            try {
                jobj = new JSONObject(results);

                if (jobj != null) {

                    jobj2 = jobj.getJSONObject(specialId);

                    if (null != jobj2) {
                        map = new HashMap<String, Object>();
                        map.put(IMGSRC_TAG,
                                jobj2.isNull(IMGSRC_TAG) ? "" : jobj2.getString(IMGSRC_TAG));
                        map.put(SDOCID_TAG,
                                jobj2.isNull(SDOCID_TAG) ? "" : jobj2.getString(SDOCID_TAG));
                        map.put(SNAME_TAG,
                                jobj2.isNull(SNAME_TAG) ? "" : jobj2.getString(SNAME_TAG));
                        map.put(TITLE_TAG,
                                jobj2.isNull(SNAME_TAG) ? "" : jobj2.getString(SNAME_TAG));
                        map.put(SUBTITLE_TAG,
                                jobj2.isNull(SUBTITLE_TAG) ? "" : jobj2.getString(SUBTITLE_TAG));
                        map.put(DOCID_TAG,
                                jobj2.isNull(SDOCID_TAG) ? "" : jobj2.getString(SDOCID_TAG));
                        map.put(DIGEST_TAG,
                                jobj2.isNull(DIGEST_TAG) ? "" : jobj2.getString(DIGEST_TAG));
                        map.put(URL_TAG, jobj2.isNull(URL_TAG) ? "" : jobj2.getString(URL_TAG));
                        map.put(PTIME_TAG,
                                jobj2.isNull(PTIME_TAG) ? "" : jobj2.getString(PTIME_TAG));
                        map.put(REPLYCOUNT_TAG,
                                jobj2.isNull(REPLYCOUNT_TAG) ? "0" + "跟贴" : jobj2
                                        .getString(REPLYCOUNT_TAG) + "跟贴");
                        map.put(SPECIAL_INDEX_TAG, "0");
                        list.add(map);

                        // 专题增加banner//
                        String banner = jobj2.isNull(SPECIAL_BANNER) ? "" : jobj2
                                .getString(SPECIAL_BANNER);
                        if (!"".equals(banner)) {
                            SharedPreferences sp = mContext.getSharedPreferences(
                                    StringUtil.PREFERENCE_SPECIAL_BANNER, Context.MODE_PRIVATE);
                            Editor edit = sp.edit();
                            edit.putString(specialId, banner);
                            edit.commit();
                        }

                        jsonArray = jobj2.getJSONArray("topics");
                        for (int j = 0; jsonArray != null && j < jsonArray.length(); j++) {
                            jobj3 = jsonArray.getJSONObject(j);
                            int index = jobj3.getInt(SPECIAL_INDEX_TAG);
                            String tname = jobj3.getString(SPECIAL_TNAME_TAG);
                            jsonArray2 = jobj3.getJSONArray("docs");

                            for (int i = 0; jsonArray2 != null && i < jsonArray2.length(); i++) {
                                jobj4 = jsonArray2.getJSONObject(i);
                                map = new HashMap<String, Object>();
                                map.put(IMGSRC_TAG,
                                        jobj4.isNull(IMGSRC_TAG) ? "" : jobj4.getString(IMGSRC_TAG));
                                map.put(PTIME_TAG,
                                        jobj4.isNull(PTIME_TAG) ? "" : jobj4.getString(PTIME_TAG));
                                map.put(TITLE_TAG,
                                        jobj4.isNull(TITLE_TAG) ? "" : jobj4.getString(TITLE_TAG));
                                map.put(SUBTITLE_TAG,
                                        jobj4.isNull(SUBTITLE_TAG) ? "" : jobj4
                                                .getString(SUBTITLE_TAG));
                                map.put(REPLYCOUNT_TAG, jobj4.isNull(REPLYCOUNT_TAG) ? "0" + "跟贴"
                                        : jobj4.getString(REPLYCOUNT_TAG) + "跟贴");
                                map.put(DOCID_TAG,
                                        jobj4.isNull(DOCID_TAG) ? "" : jobj4.getString(DOCID_TAG));
                                String digest = jobj2.isNull(DIGEST_TAG) ? "" : jobj2
                                        .getString(DIGEST_TAG);
                                digest = Tools.htmlDecoder(digest);
                                digest = digest.length() > 30 ? digest.substring(0, 28) + ".."
                                        : digest;
                                map.put(DIGEST_TAG, digest);
                                map.put(URL_TAG,
                                        jobj4.isNull(URL_TAG) ? "" : jobj4.getString(URL_TAG));
                                map.put(SPECIAL_INDEX_TAG, "" + index);
                                if (i == 0) {
                                    map.put(SPECIAL_TNAME_TAG, tname);
                                } else {
                                    map.put(SPECIAL_TNAME_TAG, "");
                                }
                                map.put(HASIMG_TAG, "0");
                                map.put(SPECIAL_ID_TAG, "");

                                // 加入扩展域
                                map.put(EX_JSON_TAG, Tools.getExtendJson(jobj4).toString());

                                list.add(map);
                                // 继续加
                            }

                        }

                    }

                }
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                NeteaseHttpClient.removeCache(mContext, url);
            }
        }

        if (list != null && list.size() > 0) {
            StringUtil.updateRefreshTime(mContext, specialId);
        }
        return list;
    }

    public static List<Map<String, Object>> getArticleList(
            String columnUrl, String columnId, int start, int length, Context mContext) {
        return getArticleList(columnUrl, columnId, false, start, length, mContext);
    }

    public static List<Map<String, Object>> getArticleList(
            String columnUrl, String columnId, boolean needEncode, int start, int length,
            Context mContext) {
        return getArticleList(columnUrl, columnId, needEncode, false, start, length, mContext);
    }

    public static List<Map<String, Object>> getArticleList(String columnUrl, String columnId,
            boolean needEncode,
            boolean hasHeader, int start, int length, Context mContext) {

        List<Map<String, Object>> list = null;

        JSONArray jsonArray = null;
        JSONObject jobj = null;
        JSONObject jobj2 = null;
        HashMap<String, Object> map = null;
        boolean hasimg = false;
        String url = columnUrl + (needEncode ? (StringUtil.encode(columnId)) : columnId) + "/"
                + start + "-" + length
                + ".html";
        String results = HttpUtils.getResponseFromGetUrl(url, 30000, mContext);

        if (results != null && !results.equals("")) {

            try {
                jobj = new JSONObject(results);

                if (jobj != null) {
                    jsonArray = jobj.getJSONArray(columnId);
                    StringBuilder imgsrc = null;
                    float density = mContext.getResources().getDisplayMetrics().density;
                    String imgSize = ((int) (73 * density)) + "x" + ((int) (53 * density));
                    list = new ArrayList<Map<String, Object>>();
                    for (int j = 0; jsonArray != null && j < jsonArray.length(); j++) {
//                        try {
                            jobj2 = jsonArray.getJSONObject(j);
                            map = new HashMap<String, Object>();
                            map.put(DOCID_TAG, jobj2.getString(DOCID_TAG));
                            map.put(TITLE_TAG, Tools.htmlDecoder(jobj2.getString(TITLE_TAG)));
                            map.put(REPLYCOUNT_TAG, jobj2.getInt(REPLYCOUNT_TAG) + "跟贴");
                            map.put(PTIME_TAG, jobj2.getString(PTIME_TAG));
                            map.put(URL_TAG, jobj2.getString(URL_TAG));

                            imgsrc = new StringBuilder(jobj2.getString(IMGSRC_TAG));
                            if (j == 0) {
                                Integer showimg = jobj2.getInt(HASIMG_TAG);
                                if (null != showimg) {
                                    if (showimg.intValue() == 1) {
                                        hasimg = true;
                                    }
                                }
                            }
                            if (hasimg) {
                                if (imgsrc.toString().startsWith("http://")) {
                                    if (start == 0 && j == 0 && hasHeader) {
                                        map.put(IMGSRC_TAG, imgsrc.toString());
                                    } else {
                                        imgsrc.insert("http://".length(), "s.cimg.163.com/i/");
                                        imgsrc.append(".").append(imgSize).append(".auto.jpg");
                                        map.put(IMGSRC_TAG, imgsrc.toString());
                                    }
                                } else {
                                    map.put(IMGSRC_TAG, imgsrc.toString());
                                }
                                String digest = jobj2.isNull(DIGEST_TAG) ? "" : jobj2
                                        .getString(DIGEST_TAG);
                                digest = Tools.htmlDecoder(digest);
                                digest = digest.length() > 30 ? digest.substring(0, 28) + ".."
                                        : digest;
                                map.put(DIGEST_TAG, digest);
                                map.put(HASIMG_TAG, "1");
                            } else {
                                map.put(IMGSRC_TAG, "");
                                map.put(HASIMG_TAG, "0");
                            }

                            String specialid = jobj2.isNull(SPECIAL_ID_TAG) ? "" : jobj2
                                    .getString(SPECIAL_ID_TAG);
                            map.put(SPECIAL_ID_TAG, specialid);
                            if (!"".equals(specialid)) {
                                map.put(REPLYCOUNT_TAG, "专题");
                            }

                            // 加入扩展域
                            map.put(EX_JSON_TAG, Tools.getExtendJson(jobj2).toString());
                            // 为网易博客特殊添加的默认值
                            if (StringUtil.COLUMN_TOPIC_BLOG.equals(columnId)) {
                                map.put(SUBTITLE_TAG,
                                        jobj2.isNull(SUBTITLE_TAG) ? "网易博客:" : Tools
                                                .htmlDecoder(jobj2.getString(SUBTITLE_TAG)));
                            } else {
                                map.put(SUBTITLE_TAG,
                                        jobj2.isNull(SUBTITLE_TAG) ? "" : Tools.htmlDecoder(jobj2
                                                .getString(SUBTITLE_TAG)));
                            }

                            list.add(map);
//                        } catch (Exception e) {
//                            // TODO Auto-generated catch block
//                            e.printStackTrace();
//                        }

                    }
                }
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                list = null;
                NeteaseHttpClient.removeCache(mContext, url);
            }
        }

        if (start == 0 && list != null && list.size() > 0) {
            StringUtil.updateRefreshTime(mContext, columnId);
        }

        return list;
    }

    public static ArrayList<String> getDocIdsOfArticleList(
            String columnUrl, String columnId, String start, String length, Context mContext) {
        ArrayList<String> list = new ArrayList<String>();

        JSONArray jsonArray = null;
        JSONObject jobj = null;
        JSONObject jobj2 = null;

        String url = columnUrl + columnId + "/" + start + "-" + length
                + ".html";

        String results = HttpUtils.getResponseFromGetUrl(url, 30000, mContext);

        if (results != null && !results.equals("")) {

            try {
                jobj = new JSONObject(results);

                if (jobj != null) {
                    jsonArray = jobj.getJSONArray(columnId);

                    for (int j = 0; jsonArray != null && j < jsonArray.length(); j++) {
                        try {
                            jobj2 = jsonArray.getJSONObject(j);

                            list.add(jobj2.getString(DOCID_TAG));
                        } catch (Exception e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }

                    }
                }
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                NeteaseHttpClient.removeCache(mContext, url);
            }
        }

        return list;
    }

    public static String getArticleStr(String docid, String type, Context mContext) {
        
    	String results = "";

        String url = Article_Url + docid + "/" + type + ".html";
        
        // olympic test
//        String baseUrl = "http://220.181.8.57:8080/nc/article/";
//        String url = baseUrl + docid + "/" + type + ".html";
//        
//        System.out.println("url:" + url);
        
        try {
            results = HttpUtils.getResponseFromGetUrl(url, 30000, mContext);
        } catch (Exception e) {
            e.printStackTrace();
            NeteaseHttpClient.removeCache(mContext, url);
            results = "";
        }
        
        return results;
    }

    public static HashMap<String, Object> getArticleMap(String results, String docid) {

        HashMap<String, Object> map = new HashMap<String, Object>();

        JSONObject jobj2 = null;

        if (results != null && !results.equals("")) {

            try {
                JSONObject jobj = new JSONObject(results);
                if (jobj != null) {
                    jobj2 = jobj.getJSONObject(docid);
                    if (jobj2 != null) {
                        try {
                            if (!jobj2.isNull(BODY_TAG))
                                map.put(BODY_TAG, jobj2.getString(BODY_TAG));
                            if (!jobj2.isNull(TITLE_TAG))
                                map.put(TITLE_TAG, jobj2.getString(TITLE_TAG));
                            if (!jobj2.isNull(REPLYCOUNT_TAG))
                                map.put(REPLYCOUNT_TAG, jobj2.getInt(REPLYCOUNT_TAG));
                            if (!jobj2.isNull(PTIME_TAG))
                                map.put(PTIME_TAG, jobj2.getString(PTIME_TAG));
                            if (!jobj2.isNull(SOURCE_TAG))
                                map.put(SOURCE_TAG, jobj2.getString(SOURCE_TAG));
                            if (!jobj2.isNull(REPLYBOARD_TAG))
                                map.put(REPLYBOARD_TAG, jobj2.getString(REPLYBOARD_TAG));
                            if (!jobj2.isNull(HASNEXT_TAG))
                                map.put(HASNEXT_TAG, jobj2.getBoolean(HASNEXT_TAG));
                            // ==============奥运新增
                            if (!jobj2.isNull(Videos.VURL_TAG)) // 视频分享URL
                                map.put(Videos.VURL_TAG, jobj2.getString(Videos.VURL_TAG));
                            if (jobj2.has(TEMPLATE_TAG))
                                map.put(TEMPLATE_TAG, jobj2.getString(TEMPLATE_TAG));
                            if (jobj2.has(PICNAWS_TAG))
                                map.put(PICNAWS_TAG, jobj2.getBoolean(PICNAWS_TAG));
                            if (!jobj2.isNull(VIDEO_TAG)) {
                                JSONArray videoArray = jobj2.getJSONArray(VIDEO_TAG);
                                List<Map<String, Object>> videoList = new ArrayList<Map<String, Object>>();
                                for (int i = 0; i < videoArray.length(); i++) {
                                    JSONObject videoJson = videoArray.getJSONObject(i);
                                    if (videoJson != null) {
                                        Map<String, Object> videoMap = new HashMap<String, Object>();
                                        if (videoJson.has(REF_TAG))
                                            videoMap.put(REF_TAG, videoJson.getString(REF_TAG));
                                        if (videoJson.has(COVER_TAG))
                                            videoMap.put(COVER_TAG, videoJson.getString(COVER_TAG));
                                        if (videoJson.has(MP4_URL_TAG))
                                            videoMap.put(MP4_URL_TAG,
                                                    videoJson.getString(MP4_URL_TAG));
                                        videoMap.put(MEDIA_TYPE, MEDIA_VIDEO);
                                        videoList.add(videoMap);
                                    }
                                }
                                map.put(VIDEO_TAG, videoList);
                            }
                            // ==============奥运新增
                            if (!jobj2.isNull(IMG_TAG)) {
                                JSONArray imgArray = jobj2.getJSONArray(IMG_TAG);
                                List<Map<String, Object>> imgList = new ArrayList<Map<String, Object>>();
                                for (int i = 0; i < imgArray.length(); i++) {
                                    JSONObject imgJsong = imgArray.getJSONObject(i);
                                    if (imgJsong != null) {
                                        Map<String, Object> imgMap = new HashMap<String, Object>();
                                        if (imgJsong.has(REF_TAG))
                                            imgMap.put(REF_TAG, imgJsong.getString(REF_TAG));
                                        if (imgJsong.has(ALT_TAG))
                                            imgMap.put(ALT_TAG, imgJsong.getString(ALT_TAG));
                                        if (imgJsong.has(SRC_TAG))
                                            imgMap.put(SRC_TAG, imgJsong.getString(SRC_TAG));
                                        if (imgJsong.has(PHOTOSET_ID_TAG))
                                            imgMap.put(PHOTOSET_ID_TAG,
                                                    imgJsong.getString(PHOTOSET_ID_TAG));
                                        imgMap.put(MEDIA_TYPE, MEDIA_IMAGE);
                                        imgList.add(imgMap);
                                    }
                                }
                                map.put(IMG_TAG, imgList);
                            }

                            if (!jobj2.isNull(LINK_TAG)) {
                                JSONArray linkArray = jobj2.getJSONArray(LINK_TAG);
                                List<Map<String, Object>> linkList = new ArrayList<Map<String, Object>>();
                                for (int i = 0; i < linkArray.length(); i++) {
                                    JSONObject listJson = linkArray.getJSONObject(i);
                                    if (listJson != null) {
                                        Map<String, Object> linkMap = new HashMap<String, Object>();
                                        if (listJson.has(REF_TAG))
                                            linkMap.put(REF_TAG, listJson.getString(REF_TAG));
                                        if (listJson.has(HREF_TAG))
                                            linkMap.put(HREF_TAG, listJson.getString(HREF_TAG));
                                        if (listJson.has(TITLE_TAG))
                                            linkMap.put(TITLE_TAG, listJson.getString(TITLE_TAG));
                                        if (listJson.has(TYPE_TAG))
                                            linkMap.put(TYPE_TAG, listJson.getString(TYPE_TAG));
                                        if (listJson.has(ID_TAG))
                                            linkMap.put(ID_TAG, listJson.getString(ID_TAG));
                                        linkList.add(linkMap);
                                    }
                                }
                                map.put(LINK_TAG, linkList);
                            }
                        } catch (Exception e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                    }
                }
            } catch (Exception e) {

            }

        } else {
            // Log.i("HttpUtils", "HttpUtils->results:"+results);
        }

        return map;

    }

    public static HashMap<String, Object> getArticleContents(String docid, String type,
            Context mContext) {

        String results = getArticleStr(docid, type, mContext);
        return getArticleMap(results, docid);
    }

    public static List<Map<String, Object>> getSearchNewsData(Context context, String keyword) {
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();

        String searchUrl = String.format(SearchNews_Url, StringUtil.encode(keyword));

        String results = HttpUtils.getResponseFromGetUrl(searchUrl, 3000, context);
        try {
            if (!TextUtils.isEmpty(results)) {

                JSONArray array = new JSONArray(results);

                if (null != array) {
                    int len = array.length();
                    for (int i = 0; i < len; i++) {
                        JSONObject obj = array.getJSONObject(i);
                        Map<String, Object> map = new HashMap<String, Object>();

                        map.put(TITLE_TAG,
                                obj.isNull(TITLE_TAG) ? "" : Tools.FilterCNSpace(Tools
                                        .htmlDecoder(obj.getString(TITLE_TAG).trim())));
                        map.put(PTIME_TAG, obj.isNull(PTIME_TAG) ? "" : obj.getString(PTIME_TAG)
                                .trim());
                        map.put(DOCID_TAG, obj.isNull(DOCID_TAG) ? "" : obj.getString(DOCID_TAG)
                                .trim());

                        list.add(map);

                    }

                }

            }
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            NeteaseHttpClient.removeCache(context, searchUrl);
        }

        return list;
    }

    /**
     * 获取微博数据
     * 
     * @param mContext
     * @param url
     * @return
     */
    public static List<Pair<Map<String, Object>, List<Map<String, Object>>>> getMicroHotData(
            Context mContext,
            String url) {
        // TODO Auto-generated method stub
        String result = HttpUtils.getResponseFromGetUrl(url, 30000, mContext);
        List<Pair<Map<String, Object>, List<Map<String, Object>>>> list = null;
        if (!TextUtils.isEmpty(result)) {

            try {
                JSONObject jsonObj = new JSONObject(result);
                if (null != jsonObj) {

                    JSONArray array = jsonObj.getJSONArray(WEIBO_TOPIC_TAG);

                    if (null != array && array.length() > 0) {
                        list = new ArrayList<Pair<Map<String, Object>, List<Map<String, Object>>>>();
                        int len = array.length();
                        for (int i = 0; i < len; i++) {

                            JSONObject obj = array.getJSONObject(i);
                            if (null != obj) {

                                Map<String, Object> first = new HashMap<String, Object>();
                                if (obj.has(DOCID_TAG))
                                    first.put(DOCID_TAG, obj.get(DOCID_TAG));
                                if (obj.has(TITLE_TAG))
                                    first.put(TITLE_TAG, obj.get(TITLE_TAG));
                                if (obj.has(REPLYBOARD_TAG))
                                    first.put(REPLYBOARD_TAG, obj.get(REPLYBOARD_TAG));
                                if (obj.has(REPLYCOUNT_TAG))
                                    first.put(REPLYCOUNT_TAG, obj.get(REPLYCOUNT_TAG));
                                if (obj.has(REPLYID_TAG))
                                    first.put(REPLYID_TAG, obj.get(REPLYID_TAG));
                                if (obj.has(DIGEST_TAG)) {
                                    String diget = (String) obj.get(DIGEST_TAG);
                                    first.put(DIGEST_TAG, diget.trim());
                                }
                                if (obj.has(PTIME_TAG))
                                    first.put(PTIME_TAG, obj.get(PTIME_TAG));

                                List<Map<String, Object>> second = null;
                                if (obj.has(WBLIST_TAG)) {
                                    JSONArray wbListArray = obj.getJSONArray(WBLIST_TAG);
                                    if (null != wbListArray && wbListArray.length() > 0) {
                                        int wblen = wbListArray.length();
                                        second = new ArrayList<Map<String, Object>>();
                                        for (int j = 0; j < wblen; j++) {
                                            JSONObject wbJson = wbListArray.getJSONObject(j);
                                            if (null != wbJson) {
                                                Map<String, Object> wbMap = new HashMap<String, Object>();
                                                // ============================微博图片数组==================
                                                if (wbJson.has(IMAGES_TAG)) {
                                                    JSONArray imagesArray = wbJson
                                                            .getJSONArray(IMAGES_TAG);
                                                    if (null != imagesArray
                                                            && imagesArray.length() > 0) {
                                                        int imgLen = imagesArray.length();
                                                        List<Map<String, Object>> imglist = new ArrayList<Map<String, Object>>();
                                                        for (int k = 0; k < imgLen; k++) {
                                                            JSONObject imgObj = imagesArray
                                                                    .getJSONObject(k);
                                                            if (null != imgObj) {
                                                                Map<String, Object> imgMap = new HashMap<String, Object>();
                                                                if (imgObj.has(REF_TAG))
                                                                    imgMap.put(REF_TAG,
                                                                            imgObj.get(REF_TAG));
                                                                if (imgObj.has(ALT_TAG))
                                                                    imgMap.put(ALT_TAG,
                                                                            imgObj.get(ALT_TAG));
                                                                if (imgObj.has(SRC_TAG))
                                                                    imgMap.put(SRC_TAG,
                                                                            imgObj.get(SRC_TAG));
                                                                imglist.add(imgMap);
                                                            }
                                                        }
                                                        wbMap.put(IMAGES_TAG, imglist);
                                                    }
                                                }
                                                // =======================微博图片数组==================
                                                if (wbJson.has(TEXT_TAG)) {
                                                    String text = (String) wbJson.get(TEXT_TAG);
                                                    List<Map<String, Object>> imglist = (List<Map<String, Object>>) wbMap
                                                            .get(IMAGES_TAG);
                                                    // 处理图片标签
                                                    if (null != imglist && imglist.size() > 0) {
                                                        int imgNum = imglist.size();
                                                        for (int num = 0; num < imgNum; num++) {
                                                            text = text.replace(imglist.get(num)
                                                                    .get(REF_TAG).toString(), "");
                                                        }
                                                    }

                                                    wbMap.put(TEXT_TAG, text);
                                                }
                                                // if(wbJson.has(TIME_TAG))
                                                // wbMap.put(TIME_TAG,
                                                // wbJson.get(TIME_TAG));
                                                if (wbJson.has(URL_TAG))
                                                    wbMap.put(URL_TAG, wbJson.get(URL_TAG));
                                                if (wbJson.has(M_URL_TAG))
                                                    wbMap.put(M_URL_TAG, wbJson.get(M_URL_TAG));

                                                second.add(wbMap);
                                            }
                                        }
                                    }
                                }
                                list.add(Pair.create(first, second));
                            }

                            // 修改更新时间
                            StringUtil.updateRefreshTime(mContext, HomePage.MICROHOT);

                        }

                    }
                }

            } catch (Exception e) {
                // TODO: handle exception
                NeteaseHttpClient.removeCache(mContext, url);
            }

        }
        return list;
    }

    /**
     * 网络获取视频列表
     * 
     * @param columnUrl
     * @param columnId
     * @param needEncode
     * @param hasHeader
     * @param start
     * @param length
     * @param mContext
     * @return
     */
    public static List<HashMap<String, Object>> getVideoList(
            String columnUrl, String columnId, boolean needEncode, boolean hasHeader, int start,
            int length, Context mContext) {
        List<HashMap<String, Object>> list = null;

        JSONArray jsonArray = null;
        JSONObject jobj = null;
        JSONObject jobj2 = null;
        HashMap<String, Object> map = null;

        String url = columnUrl + (needEncode ? (StringUtil.encode(columnId)) : columnId) + "/n/"
                + start + "-" + length
                + ".html";
        
        String results = HttpUtils.getResponseFromGetUrl(url, 30000, mContext);

        if (results != null && !results.equals("")) {

            try {
                
                jobj = new JSONObject(results);

                if (jobj != null) {
                    
                    list = new ArrayList<HashMap<String, Object>>();
                    jsonArray = jobj.getJSONArray(columnId);
                    StringBuilder cover = null;
                    String imgSize = getVideoListImgSize(mContext);
                    for (int j = 0; jsonArray != null && j < jsonArray.length(); j++) {
                        try {
                            jobj2 = jsonArray.getJSONObject(j);
                            map = new HashMap<String, Object>();

                            cover = new StringBuilder(jobj2.isNull(Videos.COVER_TAG) ? ""
                                    : jobj2.getString(Videos.COVER_TAG));
                            if (start == 0 && j == 0 && hasHeader) {
                                map.put(Videos.COVER_TAG, cover.toString());
                            } else if (cover.toString().startsWith("http://")) {
                                cover.insert("http://".length(), "s.cimg.163.com/i/");
                                cover.append(".").append(imgSize).append(".auto.jpg");
                                map.put(Videos.COVER_TAG, cover.toString());
                            } else {
                                map.put(Videos.COVER_TAG, cover.toString());
                            }
                            
                            String digest = jobj2.isNull(Videos.DIGEST_TAG) ? "" : jobj2
                                    .getString(Videos.DIGEST_TAG);
                            digest = Tools.htmlDecoder(digest);
                            map.put(Videos.DIGEST_ALL_TAG, digest);

                            digest = digest.length() > 30 ? digest.substring(0, 28) + ".." : digest;
                            map.put(Videos.DIGEST_TAG, digest);

                            map.put(Videos.HITS_TAG,
                                    jobj2.isNull(Videos.HITS_TAG) ? "0播放" : jobj2
                                            .getString(Videos.HITS_TAG) + "播放");
                            map.put(Videos.LENGTH_TAG, jobj2.isNull(Videos.LENGTH_TAG) ? "0"
                                    : jobj2.getString(Videos.LENGTH_TAG));
                            map.put(Videos.MP4URL_TAG,
                                    jobj2.isNull(Videos.MP4URL_TAG) ? "" : jobj2
                                            .getString(Videos.MP4URL_TAG));
                            map.put(Videos.REPLYBOARD_TAG, jobj2.isNull(Videos.REPLYBOARD_TAG) ? ""
                                    : jobj2.getString(Videos.REPLYBOARD_TAG));
                            map.put(Videos.REPLYCOUNT_TAG,
                                    jobj2.isNull(Videos.REPLYCOUNT_TAG) ? "0跟贴" : jobj2
                                            .getString(Videos.REPLYCOUNT_TAG) + "跟贴");
                            map.put(Videos.REPLYID_TAG, jobj2.isNull(Videos.REPLYID_TAG) ? ""
                                    : jobj2.getString(Videos.REPLYID_TAG));
                            map.put(Videos.TITLE_TAG, Tools.htmlDecoder(jobj2
                                    .isNull(Videos.TITLE_TAG) ? "" : jobj2
                                    .getString(Videos.TITLE_TAG)));
                            map.put(Videos.VID_TAG,
                                    jobj2.isNull(Videos.VID_TAG) ? "" : jobj2
                                            .getString(Videos.VID_TAG));
                            map.put(Videos.VURL_TAG,
                                    jobj2.isNull(Videos.VURL_TAG) ? "" : jobj2
                                            .getString(Videos.VURL_TAG));
                            map.put(Videos.PTIME_TAG,
                                    jobj2.isNull(Videos.PTIME_TAG) ? "" : jobj2
                                            .getString(Videos.PTIME_TAG));
                            map.put(Videos.EX_JSON_TAG, Tools.getExtendJson(jobj2).toString());
//                            System.out.println("net urls:" + map.get(Videos.VURL_TAG));
                            list.add(map);

                        } catch (Exception e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }

                    }
                }
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                NeteaseHttpClient.removeCache(mContext, url);
            }
        }

        if (start == 0 && null!=list && list.size() > 0) {
            StringUtil.updateRefreshTime(mContext, columnId);
        }

        return list;
    }

    public static String getVideoListImgSize(Context context) {
    	float density = context.getResources().getDisplayMetrics().density;
        String imgSize = ((int) (73 * density)) + "x" + ((int) (53 * density));
		return imgSize;
	}

	public static ArrayList<Pair<Map<String, Object>, List<Map<String, Object>>>> getDayScheduleData(
            Context mContext,
            String url) {
        String result = HttpUtils.getResponseFromGetUrl(url, 30000, mContext);
        ArrayList<Pair<Map<String, Object>, List<Map<String, Object>>>> list = null;
        if (!TextUtils.isEmpty(result)) {
            JSONArray array;
            try {
                array = new JSONArray(result);

                List<Map<String, Object>> projectlist = new ArrayList<Map<String, Object>>();
                if (null != array && array.length() > 0) {
                    list = new ArrayList<Pair<Map<String, Object>, List<Map<String, Object>>>>();
                    for (int num = 0; num < array.length(); num++)
                    {
                        JSONObject obj = array.getJSONObject(num);
                        if (obj != null)
                        {
                            Map<String, Object> group = new HashMap<String, Object>(); // 用于存储category
                            if (obj.has(PROJECT_NAME))
                                group.put(PROJECT_NAME, obj.getString(PROJECT_NAME));

                            List<Map<String, Object>> grouplist = new ArrayList<Map<String, Object>>(); // 用于存储此category下的大项目
                            List<List<Map<String, String>>> childlist = new ArrayList<List<Map<String, String>>>(); // 用于存储每一个大项目下的小项目
                            if (obj.has(PROJECT_LIST))
                            {
                                JSONArray matcharray = obj.getJSONArray(PROJECT_LIST);
                                if (matcharray != null)
                                    for (int i = 0; i < matcharray.length(); i++)
                                    {
                                        JSONObject match = matcharray.getJSONObject(i);
                                        if (match != null) {
                                            Map<String, Object> matchdetail = new HashMap<String, Object>(); // 用于存储此category下的每一个大项目
                                            if (match.has(MATCH_TIME))
                                                matchdetail
                                                        .put(MATCH_TIME,
                                                                match.getString(MATCH_TIME));
                                            if (match.has(MATCH_NAME))
                                                matchdetail
                                                        .put(MATCH_NAME,
                                                                match.getString(MATCH_NAME));
                                            List<Map<String, String>> gamelist = new ArrayList<Map<String, String>>(); // 用于存储大项目下的小项目
                                            if (match.has(MATCH_LIST))
                                            {
                                                JSONArray gamearray = match
                                                        .getJSONArray(MATCH_LIST);
                                                if (gamearray != null && gamearray.length() > 0)
                                                    for (int j = 0; j < gamearray.length(); j++)
                                                    {
                                                        JSONObject gameobj = gamearray
                                                                .getJSONObject(j);
                                                        Map<String, String> gamedetail = new HashMap<String, String>();
                                                        if (gameobj.has(GAME_START))
                                                            gamedetail.put(GAME_START,
                                                                    gameobj.getString(GAME_START));
                                                        if (gameobj.has(GAME_END))
                                                            gamedetail.put(GAME_END,
                                                                    gameobj.getString(GAME_END));
                                                        if (gameobj.has(GAME_NAME))
                                                            gamedetail.put(GAME_NAME,
                                                                    gameobj.getString(GAME_NAME));
                                                        if (gameobj.has(GAME_MEDAL))
                                                            gamedetail.put(GAME_MEDAL,
                                                                    gameobj.getString(GAME_MEDAL));
                                                        gamelist.add(gamedetail);
                                                    }
                                            }
                                            grouplist.add(matchdetail);
                                            childlist.add(gamelist);
                                        }
                                    }
                                Map<String, Object> project = new HashMap<String, Object>();
                                project.put("group", grouplist);
                                // project.put("child", childlist);
                                projectlist.add(project);
                            }
                            list.add(Pair.create(group, grouplist));
                        }
                    }
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }

        }
        return list;
    }

    public static ArrayList<Pair<Map<String, Object>, List<Map<String, Object>>>> getItemScheduleData(
            Context mContext, String url) {
        String result = HttpUtils.getResponseFromGetUrl(url, 30000, mContext);
        ArrayList<Pair<Map<String, Object>, List<Map<String, Object>>>> list = null;
        if (!TextUtils.isEmpty(result)) {
            JSONArray array;
            try {
                array = new JSONArray(result);

                List<Map<String, Object>> projectlist = new ArrayList<Map<String, Object>>();
                if (null != array && array.length() > 0) {
                    list = new ArrayList<Pair<Map<String, Object>, List<Map<String, Object>>>>();
                    for (int num = 0; num < array.length(); num++)
                    {
                        JSONObject obj = array.getJSONObject(num);
                        if (obj != null)
                        {
                            Map<String, Object> group = new HashMap<String, Object>(); // 用于存储date
                            if (obj.has(GAME_DATE))
                                group.put(GAME_DATE, obj.getString(GAME_DATE));

                            List<Map<String, Object>> grouplist = new ArrayList<Map<String, Object>>(); // 用于存储此category下的大项目
                            List<List<Map<String, String>>> childlist = new ArrayList<List<Map<String, String>>>(); // 用于存储每一个大项目下的小项目
                            if (obj.has(PROJECT_LIST))
                            {
                                JSONArray matcharray = obj.getJSONArray(PROJECT_LIST);
                                if (matcharray != null)
                                    for (int i = 0; i < matcharray.length(); i++)
                                    {
                                        JSONObject match = matcharray.getJSONObject(i);

                                        if (match != null)
                                        {
                                            Map<String, Object> matchdetail = new HashMap<String, Object>(); // 用于存储此category下的每一个大项目
                                            if (match.has(MATCH_TIME))
                                                matchdetail.put(MATCH_TIME,
                                                        match.getString(MATCH_TIME));
                                            if (match.has(MATCH_NAME))
                                                matchdetail.put(MATCH_NAME,
                                                        match.getString(MATCH_NAME));
                                            List<Map<String, String>> gamelist = new ArrayList<Map<String, String>>(); // 用于存储大项目下的小项目
                                            if (match.has(MATCH_LIST))
                                            {
                                                JSONArray gamearray = match
                                                        .getJSONArray(MATCH_LIST);
                                                if (gamearray != null && gamearray.length() > 0)
                                                    for (int j = 0; j < gamearray.length(); j++)
                                                    {
                                                        JSONObject gameobj = gamearray
                                                                .getJSONObject(j);
                                                        Map<String, String> gamedetail = new HashMap<String, String>();
                                                        if (gameobj.has(GAME_START))
                                                            gamedetail.put(GAME_START,
                                                                    gameobj.getString(GAME_START));
                                                        if (gameobj.has(GAME_END))
                                                            gamedetail.put(GAME_END,
                                                                    gameobj.getString(GAME_END));
                                                        if (gameobj.has(GAME_NAME))
                                                            gamedetail.put(GAME_NAME,
                                                                    gameobj.getString(GAME_NAME));
                                                        if (gameobj.has(GAME_MEDAL))
                                                            gamedetail.put(GAME_MEDAL,
                                                                    gameobj.getString(GAME_MEDAL));
                                                        gamelist.add(gamedetail);
                                                    }
                                            }
                                            grouplist.add(matchdetail);
                                            childlist.add(gamelist);
                                        }
                                    }
                                Map<String, Object> project = new HashMap<String, Object>();
                                project.put("group", grouplist);
                                // project.put("child", childlist);
                                projectlist.add(project);
                            }
                            list.add(Pair.create(group, grouplist));
                        }
                    }
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }

        }
        return list;
    }
}
